<template>
  <div class="newsinfo">
    <header class="header">
      <h1 class="title">
        {{newsinfo.title}}
      </h1>
      <div class="span">
        <span>{{newsinfo.add_time}}</span>
        <span>点击{{newsinfo.click}}次</span>
      </div>
    </header>
    <div class="connent">
      {{newsinfo.content}}
    </div>
    <!-- 评论区 -->
    <Comment></Comment>
  </div>
</template>
<script>
import Comment from '@/components/comment'
export default {
  data: () => ({
    id: '',
    newsinfo: []
  }),
  created() {
    this.id = this.$route.params.id
    this.getNewsInfo()
  },
  methods: {
    async getNewsInfo() {
      try {
        const { data: { message } } = await this.Api.getNewsInfo(this.id)
        this.newsinfo = message
        // console.log(message)
      } catch (error) {
        this.$Toast('请求新闻详情失败...' + error.message)
      }
    }
  },
  components: {
    Comment
  }
}
</script>
<style lang="less" scoped>
.newsinfo{
   .header{
      border-bottom: 1px solid #eeeeee;
      margin-bottom: 5px;
  .title{
    font-size: 16px;
    color: red;
    text-align: center;
  }
  .span{
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    margin-top:10px;
  }
   }
}
</style>
